package agents.resources;

import java.util.ArrayList;
import model.Model;
import model.info.Coordinate;
import model.mapping.MapPoint;

public class DriverResource {
	
	private Model model;
	private int radius;
	private ArrayList<MapPoint> initialPlace;
	private ArrayList<MapPoint> freeMirrorPoints;
	private ArrayList<MapPoint> occupedMirrorPoints;
	
	public DriverResource(Model model,int typeVehicle) {
		
		this.model = model;
		initialPlace = new ArrayList<MapPoint>();
		freeMirrorPoints = new ArrayList<MapPoint>();
		occupedMirrorPoints = new ArrayList<MapPoint>();
		radius = getZoomToRadius(this.model.getMapPanel().getZoom(),typeVehicle);
	}

	public ArrayList<MapPoint> getInitialPlace() {
		return initialPlace;
	}

	public void setInitialPlace(ArrayList<MapPoint> initialPlace) {
		this.initialPlace = initialPlace;
	}

	public ArrayList<MapPoint> getFreeMirrorPoints() {
		return freeMirrorPoints;
	}

	public void setFreeMirrorPoints(ArrayList<MapPoint> freeMirrorPoints) {
		this.freeMirrorPoints = freeMirrorPoints;
	}

	public ArrayList<MapPoint> getOccupedMirrorPoints() {
		return occupedMirrorPoints;
	}

	public void setOccupedMirrorPoints(ArrayList<MapPoint> occupedMirrorPoints) {
		this.occupedMirrorPoints = occupedMirrorPoints;
	}
	
	public int getRadius() {
		return radius;
	}

	public void setRadius(int radius) {
		this.radius = radius;
	}

	public int getZoomToRadius(int zoom,int vehicle) {
		
		int radius = 3;
		
		return radius;
	}
	
	/*
	public Point getPointInPosition(Integer lastMovement,Integer lookingAtPosition,
		int x,int y) {
		
		Point point = new Point();
		if (lastMovement.equals(Directions.Arriba.ordinal())) {
			if (lookingAtPosition.equals(Positions.Frontal.ordinal())) {
				point.x = x;
				point.y = y-1;
			}
			else if (lookingAtPosition.equals(Positions.Atras.ordinal())) {
				point.x = x;
				point.y = y+1;
			}
			else if (lookingAtPosition.equals(Positions.Derecha.ordinal())) {
				point.x = x+1;
				point.y = y;
			}
			else if (lookingAtPosition.equals(Positions.Izquierda.ordinal())) {
				point.x = x-1;
				point.y = y;
			}
			else if (lookingAtPosition.equals(Positions.FrontDer.ordinal())) {
				point.x = x+1;
				point.y = y-1;
			}
			else if (lookingAtPosition.equals(Positions.FrontIzq.ordinal())) {
				point.x = x-1;
				point.y = y-1;
			}
			else if (lookingAtPosition.equals(Positions.AtDer.ordinal())) {
				point.x = x+1;
				point.y = y+1;
			}
			else if (lookingAtPosition.equals(Positions.AtIzq.ordinal())) {
				point.x = x-1;
				point.y = y+1;
			}
		}
		else if (lastMovement.equals(Directions.Abajo.ordinal())) {
			if (lookingAtPosition.equals(Positions.Frontal.ordinal())) {
				point.x = x;
				point.y = y+1;
			}
			else if (lookingAtPosition.equals(Positions.Atras.ordinal())) {
				point.x = x;
				point.y = y-1;
			}
			else if (lookingAtPosition.equals(Positions.Derecha.ordinal())) {
				point.x = x-1;
				point.y = y;
			}
			else if (lookingAtPosition.equals(Positions.Izquierda.ordinal())) {
				point.x = x+1;
				point.y = y;
			}
			else if (lookingAtPosition.equals(Positions.FrontDer.ordinal())) {
				point.x = x-1;
				point.y = y+1;
			}
			else if (lookingAtPosition.equals(Positions.FrontIzq.ordinal())) {
				point.x = x+1;
				point.y = y+1;
			}
			else if (lookingAtPosition.equals(Positions.AtDer.ordinal())) {
				point.x = x-1;
				point.y = y-1;
			}
			else if (lookingAtPosition.equals(Positions.AtIzq.ordinal())) {
				point.x = x+1;
				point.y = y-1;
			}
		}
		else if (lastMovement.equals(Directions.Derecha.ordinal())) {
			if (lookingAtPosition.equals(Positions.Frontal.ordinal())) {
				point.x = x+1;
				point.y = y;
			}
			else if (lookingAtPosition.equals(Positions.Atras.ordinal())) {
				point.x = x-1;
				point.y = y;
			}
			else if (lookingAtPosition.equals(Positions.Derecha.ordinal())) {
				point.x = x;
				point.y = y+1;
			}
			else if (lookingAtPosition.equals(Positions.Izquierda.ordinal())) {
				point.x = x;
				point.y = y-1;
			}
			else if (lookingAtPosition.equals(Positions.FrontDer.ordinal())) {
				point.x = x+1;
				point.y = y+1;
			}
			else if (lookingAtPosition.equals(Positions.FrontIzq.ordinal())) {
				point.x = x+1;
				point.y = y-1;
			}
			else if (lookingAtPosition.equals(Positions.AtDer.ordinal())) {
				point.x = x-1;
				point.y = y+1;
			}
			else if (lookingAtPosition.equals(Positions.AtIzq.ordinal())) {
				point.x = x-1;
				point.y = y-1;
			}
		}
		else if (lastMovement.equals(Directions.Izquierda.ordinal())) {
			if (lookingAtPosition.equals(Positions.Frontal.ordinal())) {
				point.x = x-1;
				point.y = y;
			}
			else if (lookingAtPosition.equals(Positions.Atras.ordinal())) {
				point.x = x+1;
				point.y = y;
			}
			else if (lookingAtPosition.equals(Positions.Derecha.ordinal())) {
				point.x = x;
				point.y = y-1;
			}
			else if (lookingAtPosition.equals(Positions.Izquierda.ordinal())) {
				point.x = x;
				point.y = y+1;
			}
			else if (lookingAtPosition.equals(Positions.FrontDer.ordinal())) {
				point.x = x-1;
				point.y = y-1;
			}
			else if (lookingAtPosition.equals(Positions.FrontIzq.ordinal())) {
				point.x = x-1;
				point.y = y+1;
			}
			else if (lookingAtPosition.equals(Positions.AtDer.ordinal())) {
				point.x = x+1;
				point.y = y-1;
			}
			else if (lookingAtPosition.equals(Positions.AtIzq.ordinal())) {
				point.x = x+1;
				point.y = y+1;
			}
		}
		else if (lastMovement.equals(Directions.ArrDer.ordinal())) {
			if (lookingAtPosition.equals(Positions.Frontal.ordinal())) {
				point.x = x+1;
				point.y = y-1;
			}
			else if (lookingAtPosition.equals(Positions.Atras.ordinal())) {
				point.x = x-1;
				point.y = y+1;
			}
			else if (lookingAtPosition.equals(Positions.Derecha.ordinal())) {
				point.x = x+1;
				point.y = y+1;
			}
			else if (lookingAtPosition.equals(Positions.Izquierda.ordinal())) {
				point.x = x-1;
				point.y = y-1;
			}
			else if (lookingAtPosition.equals(Positions.FrontDer.ordinal())) {
				point.x = x+1;
				point.y = y;
			}
			else if (lookingAtPosition.equals(Positions.FrontIzq.ordinal())) {
				point.x = x;
				point.y = y-1;
			}
			else if (lookingAtPosition.equals(Positions.AtDer.ordinal())) {
				point.x = x;
				point.y = y+1;
			}
			else if (lookingAtPosition.equals(Positions.AtIzq.ordinal())) {
				point.x = x-1;
				point.y = y;
			}
		}
		else if (lastMovement.equals(Directions.ArrIzq.ordinal())) {
			if (lookingAtPosition.equals(Positions.Frontal.ordinal())) {
				point.x = x-1;
				point.y = y-1;
			}
			else if (lookingAtPosition.equals(Positions.Atras.ordinal())) {
				point.x = x+1;
				point.y = y+1;
			}
			else if (lookingAtPosition.equals(Positions.Derecha.ordinal())) {
				point.x = x+1;
				point.y = y-1;
			}
			else if (lookingAtPosition.equals(Positions.Izquierda.ordinal())) {
				point.x = x-1;
				point.y = y+1;
			}
			else if (lookingAtPosition.equals(Positions.FrontDer.ordinal())) {
				point.x = x;
				point.y = y-1;
			}
			else if (lookingAtPosition.equals(Positions.FrontIzq.ordinal())) {
				point.x = x-1;
				point.y = y;
			}
			else if (lookingAtPosition.equals(Positions.AtDer.ordinal())) {
				point.x = x+1;
				point.y = y;
			}
			else if (lookingAtPosition.equals(Positions.AtIzq.ordinal())) {
				point.x = x;
				point.y = y+1;
			}
		}
		else if (lastMovement.equals(Directions.AbDer.ordinal())) {
			if (lookingAtPosition.equals(Positions.Frontal.ordinal())) {
				point.x = x+1;
				point.y = y+1;
			}
			else if (lookingAtPosition.equals(Positions.Atras.ordinal())) {
				point.x = x-1;
				point.y = y-1;
			}
			else if (lookingAtPosition.equals(Positions.Derecha.ordinal())) {
				point.x = x-1;
				point.y = y+1;
			}
			else if (lookingAtPosition.equals(Positions.Izquierda.ordinal())) {
				point.x = x+1;
				point.y = y-1;
			}
			else if (lookingAtPosition.equals(Positions.FrontDer.ordinal())) {
				point.x = x;
				point.y = y+1;
			}
			else if (lookingAtPosition.equals(Positions.FrontIzq.ordinal())) {
				point.x = x+1;
				point.y = y;
			}
			else if (lookingAtPosition.equals(Positions.AtDer.ordinal())) {
				point.x = x-1;
				point.y = y;
			}
			else if (lookingAtPosition.equals(Positions.AtIzq.ordinal())) {
				point.x = x;
				point.y = y-1;
			}
		}
		else if (lastMovement.equals(Directions.AbIzq.ordinal())) {
			if (lookingAtPosition.equals(Positions.Frontal.ordinal())) {
				point.x = x-1;
				point.y = y+1;
			}
			else if (lookingAtPosition.equals(Positions.Atras.ordinal())) {
				point.x = x+1;
				point.y = y-1;
			}
			else if (lookingAtPosition.equals(Positions.Derecha.ordinal())) {
				point.x = x-1;
				point.y = y-1;
			}
			else if (lookingAtPosition.equals(Positions.Izquierda.ordinal())) {
				point.x = x+1;
				point.y = y+1;
			}
			else if (lookingAtPosition.equals(Positions.FrontDer.ordinal())) {
				point.x = x-1;
				point.y = y;
			}
			else if (lookingAtPosition.equals(Positions.FrontIzq.ordinal())) {
				point.x = x;
				point.y = y+1;
			}
			else if (lookingAtPosition.equals(Positions.AtDer.ordinal())) {
				point.x = x;
				point.y = y-1;
			}
			else if (lookingAtPosition.equals(Positions.AtIzq.ordinal())) {
				point.x = x+1;
				point.y = y;
			}
		}
		return point;
	}

	/*
	public int nextAgentDirection(AgentInfoOptionPlace actual,
		AgentInfoOptionPlace siguiente) {
		
		int x = actual.getX();
		int y = actual.getY();
		int i = actual.getX();
		int j = actual.getY();
		int resultado = -1;
		switch(actual.getRoadDirection()) { //Dudando
		case 0: //OK
			if (i > x && j > y)
				resultado = Positions.AtDer.ordinal();
			else if (i > x && j < y)
				resultado = Positions.FrontDer.ordinal();
			else if (i < x && j > y)
				resultado = Positions.AtIzq.ordinal();
			else if (i < x && j < y)
				resultado = Positions.FrontIzq.ordinal();
			else if (i == x && j > y)
				resultado = Positions.Atras.ordinal();
			else if (i == x && j < y)
				resultado = Positions.Frontal.ordinal();
			else if (i > x && j == y)
				resultado = Positions.Derecha.ordinal();
			else if (i < x && j == y)
				resultado = Positions.Izquierda.ordinal();
			break;
		case 1: //OK
			if (i > x && j > y)
				resultado = Positions.FrontIzq.ordinal();
			else if (i > x && j < y)
				resultado = Positions.AtIzq.ordinal();
			else if (i < x && j > y)
				resultado = Positions.FrontDer.ordinal();
			else if (i < x && j < y)
				resultado = Positions.AtDer.ordinal();
			else if (i == x && j > y)
				resultado = Positions.Frontal.ordinal();
			else if (i == x && j < y)
				resultado = Positions.Atras.ordinal();
			else if (i > x && j == y)
				resultado = Positions.Izquierda.ordinal();
			else if (i < x && j == y)
				resultado = Positions.Derecha.ordinal();
			break;
		case 2: //OK
			if (i > x && j > y)
				resultado = Positions.FrontDer.ordinal();
			else if (i > x && j < y)
				resultado = Positions.FrontIzq.ordinal();
			else if (i < x && j > y)
				resultado = Positions.AtDer.ordinal();
			else if (i < x && j < y)
				resultado = Positions.AtIzq.ordinal();
			else if (i == x && j > y)
				resultado = Positions.Derecha.ordinal();
			else if (i == x && j < y)
				resultado = Positions.Izquierda.ordinal();
			else if (i > x && j == y)
				resultado = Positions.Frontal.ordinal();
			else if (i < x && j == y)
				resultado = Positions.Atras.ordinal();
			break;
		case 3: //OK
			if (i > x && j > y)
				resultado = Positions.AtIzq.ordinal();
			else if (i > x && j < y)
				resultado = Positions.AtDer.ordinal();
			else if (i < x && j > y)
				resultado = Positions.FrontIzq.ordinal();
			else if (i < x && j < y)
				resultado = Positions.FrontDer.ordinal();
			else if (i == x && j > y)
				resultado = Positions.Izquierda.ordinal();
			else if (i == x && j < y)
				resultado = Positions.Derecha.ordinal();
			else if (i > x && j == y)
				resultado = Positions.Atras.ordinal();
			else if (i < x && j == y)
				resultado = Positions.Frontal.ordinal();
			break;
		case 4: //OK
			if (i > x && j > y)
				resultado = Positions.Derecha.ordinal();
			else if (i > x && j < y)
				resultado = Positions.Frontal.ordinal();
			else if (i < x && j > y)
				resultado = Positions.Atras.ordinal();
			else if (i < x && j < y)
				resultado = Positions.Izquierda.ordinal();
			else if (i == x && j > y)
				resultado = Positions.AtDer.ordinal();
			else if (i == x && j < y)
				resultado = Positions.FrontIzq.ordinal();
			else if (i > x && j == y)
				resultado = Positions.FrontDer.ordinal();
			else if (i < x && j == y)
				resultado = Positions.AtIzq.ordinal();
			break;
		case 5: //OK
			if (i > x && j > y)
				resultado = Positions.Atras.ordinal();
			else if (i > x && j < y)
				resultado = Positions.Derecha.ordinal();
			else if (i < x && j > y)
				resultado = Positions.Izquierda.ordinal();
			else if (i < x && j < y)
				resultado = Positions.Frontal.ordinal();
			else if (i == x && j > y)
				resultado = Positions.AtIzq.ordinal();
			else if (i == x && j < y)
				resultado = Positions.FrontDer.ordinal();
			else if (i > x && j == y)
				resultado = Positions.AtDer.ordinal();
			else if (i < x && j == y)
				resultado = Positions.FrontIzq.ordinal();
			break;
		case 6: //OK
			if (i > x && j > y)
				resultado = Positions.Frontal.ordinal();
			else if (i > x && j < y)
				resultado = Positions.Izquierda.ordinal();
			else if (i < x && j > y)
				resultado = Positions.Derecha.ordinal();
			else if (i < x && j < y)
				resultado = Positions.Atras.ordinal();
			else if (i == x && j > y)
				resultado = Positions.FrontDer.ordinal();
			else if (i == x && j < y)
				resultado = Positions.AtIzq.ordinal();
			else if (i > x && j == y)
				resultado = Positions.FrontIzq.ordinal();
			else if (i < x && j == y)
				resultado = Positions.AtDer.ordinal();
			break;
		case 7: 
			if (i > x && j > y)
				resultado = Positions.Izquierda.ordinal();
			else if (i > x && j < y)
				resultado = Positions.Atras.ordinal();
			else if (i < x && j > y)
				resultado = Positions.Frontal.ordinal();
			else if (i < x && j < y)
				resultado = Positions.Derecha.ordinal();
			else if (i == x && j > y)
				resultado = Positions.FrontIzq.ordinal();
			else if (i == x && j < y)
				resultado = Positions.AtDer.ordinal();
			else if (i > x && j == y)
				resultado = Positions.AtIzq.ordinal();
			else if (i < x && j == y)
				resultado = Positions.FrontDer.ordinal();
			break;
		}
		return resultado;
	}*/
}
